package com.mayisoftware.mayioa.business.human.impl.serviceImpl;


import com.mayisoftware.mayioa.business.human.api.domain.HCUploadInfo;
import com.mayisoftware.mayioa.business.human.api.service.IHCUploadService;
import com.mayisoftware.mayioa.business.human.impl.dao.HCUploadMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service
public class HCUploasdServiceImpl implements IHCUploadService {

    @Autowired
    private HCUploadMapper importMapper;


    @Override
    public int insertImportOneRecord(HCUploadInfo uploadInfo) {
        return importMapper.insertImportOneRecord(uploadInfo);
    }

    @Override
    public List<HCUploadInfo> queryRecordList(HCUploadInfo uploadInfo) {
        return importMapper.selectRecordList(uploadInfo);
    }

    @Override
    public List<HCUploadInfo> queryRecordListById(String recordId) {
        return importMapper.selectRecordListById(recordId);
    }

    @Override
    public List<HCUploadInfo> queryRecordListNeedParse() {
        return importMapper.selectRecordListNeedParse();
    }

    @Override
    public int editInputRecord(HCUploadInfo record) {
        return importMapper.updateInputRecord(record);
    }

    @Override
    public String getCheckPeriod(Date invalidDate) {

        String period = "";
        Calendar ca = Calendar.getInstance();

        ca.setTime(invalidDate);
        int month = ca.get(Calendar.MONTH);//第几个月
        int year = ca.get(Calendar.YEAR);//年份数值

        period+=year+"H";
        if (month<=6){
            period+=1;
        }else{
            period+=2;
        }

        return period;
    }
}
